package com.ml.mall.service.impl;

import com.ml.mall.bean.page.Page;
import com.ml.mall.bean.req.BaseDateRangeReq;
import com.ml.mall.bean.req.admin.category.AdminCategoryQueryPageReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryOneReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryPageReq;
import com.ml.mall.bean.req.admin.coupon.CouponQueryUseNumReq;
import com.ml.mall.bean.req.admin.purchase.PurchaseQueryReportPageReq;
import com.ml.mall.bean.req.admin.supplier.SupplierQueryOneReq;
import com.ml.mall.bean.res.admin.category.AdminCategoryQueryPageRes;
import com.ml.mall.bean.res.admin.supplier.SupplierQueryOneRes;
import com.ml.mall.bean.res.order.OrderQueryPageRes;
import com.ml.mall.bean.res.partner.PartnerRegisterCompanyRes;
import com.ml.mall.bean.res.partner.PartnerSupplierQueryPageRes;
import com.ml.mall.bean.res.partner.PartnerSupplierQueryReportRes;
import com.ml.mall.bean.vo.DateValueVO;
import com.ml.mall.consts.UserRoleTypeConsts;
import com.ml.mall.entity.sys.SysUser;
import com.ml.mall.mapper.AnalyticsCouponMapper;
import com.ml.mall.security.JwtUtil;
import com.ml.mall.service.AnalyticsAdminService;
import com.ml.mall.service.AnalyticsCouponService;
import com.ml.mall.service.AnalyticsPartnersService;
import com.ml.mall.service.asyn.AnalyticsPartnerServiceAsyn;
import com.ml.mall.utils.DateTransformUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
 * Created by kyyang on 2021/6/28 23:20
 */
@Service
@Slf4j
public class AnalyticsCouponServiceImpl implements AnalyticsCouponService {

    @Autowired
    AnalyticsCouponMapper analyticsCouponMapper;

    @Override
    public List<DateValueVO> selectDayUseNumByCouponCodeAndTime(CouponQueryUseNumReq req) {
        return analyticsCouponMapper.selectCouponUseNum(req);
    }

    @Override
    public Page<OrderQueryPageRes> selectOrderByCouponCode(CouponQueryPageReq req) {
        log.info("req===={}",req);
        List<OrderQueryPageRes> orderQueryPageRes = analyticsCouponMapper.selectOrderPage(req);
        log.info("orderQueryPageRes==={}",orderQueryPageRes);
        int i = analyticsCouponMapper.selectCountOrderPage(req);
        Page<OrderQueryPageRes> pageData = new Page<>(req.getPageIndex(),req.getPageNum());
        pageData.setRecords(orderQueryPageRes);
        pageData.setTotal(i);
        return pageData;
    }
}
